﻿using System.Collections.Generic;
using System.Reflection;
using NHibernate;
using NHibernate.Cfg;
using QUANLYSINHVIEN.Domain;

namespace QUANLYSINHVIEN.Sevice
{
    public class ILopService
    {
        static ISessionFactory mySecsionFactory;
        static ISession OpenSession()
        {
            if (mySecsionFactory == null)
            {
                Configuration configuration = new Configuration();
                configuration.AddAssembly(Assembly.GetCallingAssembly());

                mySecsionFactory = configuration.BuildSessionFactory();
            }
            return mySecsionFactory.OpenSession();
        }
        public IList<Lop> LoadLop()
        {
            using (ISession mySession = OpenSession())
            {
                var a = mySession.CreateQuery("FROM Lop s").List<Lop>();
                IList<Lop> list = a;
                return list;
            }
        }
    }
}
